﻿using Stee.CAP8.MessageBus.Sagas.Core.Exceptions;
using Stee.CAP8.MessageBus.Sagas.Core.Extensions;
using Stee.CAP8.MessageBus.Sagas.Core.Sagas;
using Stee.CAP8.MessageBus.Sagas.Core.Transactions;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Stee.CAP8.MessageBus.Sagas.Core.HanlderInvokers.New
{

    /// <summary>
    /// Wrapper of the handler that is ready to invoke
    /// </summary>
    public abstract class HandleInvoker
    {

    }



    /// <summary>
    /// Derivation of the <see cref="HandlerInvoker"/> that has the message type
    /// </summary>
    public class HandleInvoker<TMessage> : HandleInvoker
    {

        private IHandleMessages<TMessage> _handleInstance;
        private Func< Task> _action;
        private TMessage _message;



        public HandleInvoker(IHandleMessages<TMessage> handleInstance, Func< Task> action, TMessage message)
        {
            this._handleInstance = handleInstance ?? throw new ArgumentNullException(nameof(handleInstance));
            _action = action ?? throw new ArgumentNullException(nameof(action));
            _message = message;
        }

        public IHandleMessages<TMessage> Handle => _handleInstance;
        public Func< Task> Action => _action;
        public TMessage Message => _message;
    }
}
